/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package id.net.iconpln.bb.server.util;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author user
 */
public class CommonModule {
	public static final String SESSION_PATH_SAMPLING = "SESSION_PATH_SAMPLING";

    public static List<Map> convertResultsetToListLower(ResultSet rs) throws SQLException{
    	List<Map> lst = new ArrayList<Map>();
    	ResultSetMetaData rsmd = rs.getMetaData();
	    int colCount = rsmd.getColumnCount();
	
	    while (rs.next()) {
	        HashMap map = new HashMap();
	        for (int i = 1; i <= colCount; i++) {
	        	try{
	        		map.put(rsmd.getColumnName(i).toLowerCase(), rs.getObject(i).toString());
	        	}catch (Exception e) {
	        		map.put(rsmd.getColumnName(i).toLowerCase(), "");
//	        		e.printStackTrace();s
				}	            
	        }
	        lst.add(map);
	    }
	    
	    return lst;
    }
    
    public static List<Map> convertResultsetToListUpper(ResultSet rs) throws SQLException{
    	List<Map> lst = new ArrayList<Map>();
    	ResultSetMetaData rsmd = rs.getMetaData();
	    int colCount = rsmd.getColumnCount();
	
	    while (rs.next()) {
	        HashMap map = new HashMap();
	        for (int i = 1; i <= colCount; i++) {
	            map.put(rsmd.getColumnName(i).toUpperCase(), rs.getObject(i).toString());
	        }
	        lst.add(map);
	    }	    
	    return lst;
    }

    public static List<Map> convertParHasilToResultSet(String gethasil) throws SQLException{
    	List<Map> lst = new ArrayList<Map>();
    	HashMap map = new HashMap();
    	map.put("gethasil", gethasil);
    	lst.add(map);	    
	    return lst;
    }
}
